package leet.ku._257;

import java.util.ArrayList;
import java.util.List;

class TreeNode {
	int val;
	TreeNode left;
	TreeNode right;

	TreeNode(int x) {
		val = x;
	}
}

public class Solution {
	public List<String> binaryTreePaths(TreeNode root) {
		List<String> result = new ArrayList<String>();
		if (root != null) {
			if (root.left == null && root.right == null)
				result.add(String.valueOf(root.val));
			else {
				if (root.left != null)
					for (String s : binaryTreePaths(root.left))
						result.add(root.val + "->" + s);
				if (root.right != null)
					for (String s : binaryTreePaths(root.right))
						result.add(root.val + "->" + s);
			}
		}
		return result;
	}
}